home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / wclrtobo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.0 KB  |  91 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    wclrtobot
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_wclrtobo = "$Header: C:\CURSES\portable\RCS\wclrtobo.c 2.1 1993/06/18 20:19:20 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   wclrtobot()    - erase window
  15.  
  16.   X/Open Description:
  17.      All lines below the cursor in this window are erased.  The current
  18.      line to the right of the cursor, inclusive, is also erased.
  19.  
  20.      NOTE:  clrtobot() is a macro.
  21.  
  22.   PDCurses Description:
  23.      There is no additional PDCurses functionality.
  24.  
  25.   X/Open Return Value:
  26.      The wclrtobot() function returns OK on success and ERR on error.
  27.  
  28.   PDCurses Errors:
  29.      It is an error to call this function with a NULL window pointer.
  30.  
  31.   Portability:
  32.      PDCurses    int wclrtobot( WINDOW* win );
  33.      X/Open Dec '88    int wclrtobot( WINDOW* win );
  34.      BSD Curses    int wclrtobot( WINDOW* win );
  35.      SYS V Curses    int wclrtobot( WINDOW* win );
  36.  
  37. **man-end**********************************************************************/
  38.  
  39. int    wclrtobot(WINDOW *win)
  40. {
  41.     int    y;
  42.     int    minx;
  43.     int    startx;
  44.     chtype    blank;
  45.     chtype*    ptr;
  46.     chtype*    end;
  47.     chtype*    maxx;
  48.  
  49. #ifdef PDCDEBUG
  50.     if (trace_on) PDC_debug("wclrtobot() - called\n");
  51. #endif
  52.  
  53.     if  (win == (WINDOW *)NULL)
  54.         return( ERR );
  55.  
  56.     blank    = win->_blank | win->_attrs;
  57.     startx    = win->_curx;
  58.  
  59.     for (y = win->_cury; y <= win->_bmarg; y++)
  60.     {
  61.         minx    = _NO_CHANGE;
  62.         end    = &win->_y[y][win->_maxx - 1];
  63.         for (ptr = &win->_y[y][startx]; ptr <= end; ptr++)
  64.         {
  65.             if (*ptr != blank)
  66.             {
  67.                 maxx = ptr;
  68.                 if (minx == _NO_CHANGE)
  69.                 {
  70.                     minx = (int) (ptr - win->_y[y]);
  71.                 }
  72.                 *ptr = blank;
  73.             }
  74.         }
  75.         if (minx != _NO_CHANGE)
  76.         {
  77.             if ((win->_firstch[y] > minx) ||
  78.                 (win->_firstch[y] == _NO_CHANGE))
  79.             {
  80.                 win->_firstch[y] = minx;
  81.                 if (win->_lastch[y] < maxx - win->_y[y])
  82.                 {
  83.                     win->_lastch[y] = (int) (maxx - win->_y[y]);
  84.                 }
  85.             }
  86.         }
  87.         startx = 0;
  88.     }
  89.     return( OK );
  90. }
  91.